

require.config({
    paths: {
        echarts: Feng.ctxPath + '/static/js/plugins/echarts-2.2.7/build/dist'
    }
});
var sexoption = {
    title: {
        text: '商品分析',
        x: 'center'
    },
    tooltip: {
        trigger: 'item',
        formatter: "{a} <br/>{b} : {c} ({d}%)"
    },
    legend: {
        orient: 'vertical',
        x: 'left',
        data: []
    },
    toolbox: {
        show: true,
        feature: {
            mark: {show: true},
            dataView: {show: true, readOnly: false},
            magicType: {
                show: true,
                type: ['pie', 'funnel'],
                option: {
                    funnel: {
                        x: '25%',
                        width: '50%',
                        funnelAlign: 'left',
                        max: 1548
                    }
                }
            },
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    calculable: true,
    series: [
        {
            name: '分类',
            type: 'pie',
            radius: '55%',
            center: ['50%', '60%'],
            data: []
        }
    ]
};
var echarone = function () {
    require(
        [
            'echarts',
            'echarts/chart/bar',
            'echarts/chart/line',
            'echarts/chart/pie',
            'echarts/chart/map',

        ],
        function (ec) {
            var sexChart = ec.init(document.getElementById('good'));
            sexChart.setOption(sexoption);
        }
    );
};

$(function () {

    var ajax = new $ax(Feng.ctxPath + "/analysis/good", function (getdata) {
        for (var i in getdata) {


            var sexdate={};
            sexdate['name']=getdata[i]['goodname'];
            sexdate['value']=getdata[i]['goodcount'];
            sexoption['legend']['data'].push(getdata[i]['goodname']);
            sexoption['series'][0]['data'].push(sexdate);
        }
        echarone();

    }, function (data) {
        Feng.error("获取数据失败");
    });
    ajax.start();

});

